package iface;

import java.io.Serializable;
import java.util.Collection;

/**
 * An object used to indicate the status of an action.
 * 
 * @author Jeff
 * 
 */
public class Status implements Serializable, Message {

    private static final long serialVersionUID = 3L;

    public enum Result {
        SUCCESS, ERROR, INVALID;
    }

    private Result msgStatus;
    private Message.MsgType msgType;
    private String message;
    private Collection<HvZUser> locationList;

    /**
     * Constructs a new Status object
     * 
     * @param msg
     *            the message result
     * @param type
     *            the message type
     */
    public Status(Result msg, Message.MsgType type) {
        this.msgType = type;
        this.msgStatus = msg;
        this.locationList = null;
    }

    /**
     * @return the message Status
     */
    public Result getMessageStatus() {
        return msgStatus;
    }

    /**
     * @return the message
     */
    public String getMessage() {
        return message;
    }

    /**
     * @param message
     *            the message to set
     */
    public void setMessage(String message) {
        this.message = message;
    }

    /**
     * @param locationList
     *            the location list to attach
     */
    public void setLocationList(Collection<HvZUser> locationList) {
        this.locationList = locationList;
    }

    /**
     * @return the locationlist
     */
    public Collection<HvZUser> getLocationList() {
        return locationList;
    }

    /**
     * @param msgType
     *            the message type to set
     */
    public void setMessageType(Message.MsgType msgType) {
        this.msgType = msgType;
    }

    /**
     * @return the message type
     */
    public Message.MsgType getMessageType() {
        return msgType;
    }

    /**
     * @return a String representation of the a Status
     */
    public String toString() {
        // example: REGISTRAION ERROR: Database Error.
        String retStr = this.msgType + ", " + this.msgStatus + ": "
                + this.message;
        if (this.locationList != null)
            retStr += this.locationList.toString();
        return retStr;
    }

}
